Skip to content

chore: a tiny bit safer approach#482

Merged
ovflowd merged 13 commits into
mainfrom
chore/a-tiny-bit-safer-approach
Nov 9, 2025
Merged

chore: a tiny bit safer approach#482
ovflowd merged 13 commits into
mainfrom
chore/a-tiny-bit-safer-approach

Conversation

@ovflowd

@ovflowd ovflowd commented Nov 3, 2025

Copy link
Copy Markdown
Member

This PR removes the removal of files during also the crazy copy of files, deferring the out/ folder cleanup to docclean as it probably should. The original intent of the rm command was to ensure files that do not exist on source anymore and are irrelevant will be removed, but this isn't really an issue and eventually the legacy generator will go away.

Simplifed to a simple copyFile call too.

@ovflowd ovflowd requested a review from a team as a code owner November 3, 2025 22:55
Copilot AI review requested due to automatic review settings November 3, 2025 22:55
@vercel

vercel Bot commented Nov 3, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
api-docs-tooling Ready Ready Preview Nov 9, 2025 1:59am

@codecov

codecov Bot commented Nov 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.42%. Comparing base (b799808) to head (190b266).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #482      +/-   ##
==========================================
+ Coverage   74.40%   74.42%   +0.02%     
==========================================
  Files         110      110              
  Lines       10482    10468      -14     
  Branches      704      700       -4     
==========================================
- Hits         7799     7791       -8     
+ Misses       2680     2674       -6     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the safeCopy utility to use Node.js's native fs.copyFile instead of manual readFile/writeFile operations, improving efficiency and handling of concurrent operations. Additionally, it removes the aggressive cleanup step (rm) that was previously deleting the entire assets directory before copying.

Key Changes

  • Replaced readFile/writeFile with native copyFile API for better performance and atomicity
  • Removed the rm call that was deleting the entire assets directory before copying
  • Added comprehensive test coverage for the safeCopy function

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/generators/legacy-html/utils/safeCopy.mjs Refactored to use copyFile instead of manual read/write operations; updated documentation
src/generators/legacy-html/utils/tests/safeCopy.test.mjs Added comprehensive test suite covering various scenarios
src/generators/legacy-html/index.mjs Removed aggressive rm call that deleted the entire assets directory

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/__tests__/safeCopy.test.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated

This comment was marked as resolved.

@avivkeller

Copy link
Copy Markdown
Member

Whoops! I thought the bot would just make a commit, not open a whole different PR.

@ovflowd

ovflowd commented Nov 4, 2025

Copy link
Copy Markdown
Member Author

cc @aduh95 / @avivkeller / @flakey5 can y'all test if y'all see any issues with this one?

I tried:

-j
-j 32
-j 64
-j 128
-j 256

Didn't find any errors.

@avivkeller

Copy link
Copy Markdown
Member

Let's give it a try :-). If it fails in the PR (for @aduh95), we can fall back to #483

@aduh95 aduh95 self-requested a review November 5, 2025 13:21

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no longer getting errors! Left a suggestion

Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
@ovflowd

ovflowd commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

@avivkeller PR is failing

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@avivkeller

This comment was marked as resolved.

@ovflowd

This comment was marked as off-topic.

@avivkeller

This comment was marked as off-topic.

@avivkeller

This comment was marked as off-topic.

@ovflowd

This comment was marked as off-topic.

@avivkeller

Copy link
Copy Markdown
Member

@nodejs/web-infra for reviews

Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
Comment thread src/generators/legacy-html/utils/safeCopy.mjs Outdated
@ovflowd

ovflowd commented Nov 6, 2025

Copy link
Copy Markdown
Member Author

cc @aduh95 can you test the current commit, and report back if it works fine? And if it does, approve the PR? cc @nodejs/web-infra we need more reviews too.

@ovflowd

ovflowd commented Nov 7, 2025

Copy link
Copy Markdown
Member Author

Bump, @aduh95 :3

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get any errors

Comment thread src/generators/legacy-html/utils/safeCopy.mjs
Comment thread src/generators/legacy-html/utils/__tests__/safeCopy.test.mjs Outdated

@flakey5 flakey5 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but also I second #482 (comment)

@ovflowd ovflowd merged commit 0a64160 into main Nov 9, 2025
19 checks passed
@ovflowd ovflowd deleted the chore/a-tiny-bit-safer-approach branch November 9, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants